package cn.org.eshow.webapp.action.response;

import cn.org.eshow.model.Cart;

import java.util.Date;

/**
 * 购物车及药品
 */
public class CartResponse {

    private Integer id;
    private Date addTime = new Date();// 添加时间
    private String type = "";//价格类型
    private Double price = 0.0;//成交价格
    private Double origPrice = 0.0;//原价
    private Integer quantity = 0;//数量
    public UserSimpleResponse user;// 用户
    public ProductResponse product;//商品
    public ProductItemResponse productItem;//详细商品

    public CartResponse() {
    }

    public CartResponse(Cart cart) {
        this.setId(cart.getId());
        this.setAddTime(cart.getAddTime());
        this.setType(cart.getType());
        this.setPrice(cart.getPrice());
        this.setOrigPrice(cart.getOrigPrice());
        this.setQuantity(cart.getQuantity());
        if (cart.getProduct() != null){
            this.product = new ProductResponse(cart.getProduct());
        }
        if (cart.getUser() != null){
            this.user = new UserSimpleResponse(cart.getUser());
        }
        if (cart.getProductItem() != null){
            this.productItem = new ProductItemResponse(cart.getProductItem());
        }
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getOrigPrice() {
        return origPrice;
    }

    public void setOrigPrice(Double origPrice) {
        this.origPrice = origPrice;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public ProductResponse getProduct() {
        return product;
    }

    public void setProduct(ProductResponse product) {
        this.product = product;
    }

    public ProductItemResponse getProductItem() {
        return productItem;
    }

    public void setProductItem(ProductItemResponse productItem) {
        this.productItem = productItem;
    }

    public UserSimpleResponse getUser() {
        return user;
    }

    public void setUser(UserSimpleResponse user) {
        this.user = user;
    }
}
